<?php

namespace Biz\model\wiki;


class ContentWikiMiddle extends \Doraemon\pockets\datebase\BaseDbModel
{
    const _CONFIG_FILE_ = 'db_store';

    const _CONFIG_SELECT_ = 'db_store';

    const _DATABASE_ = 'store';

    const _TABLE_NAME = 'content_wiki_middle';//发布器中内容商品关联表

    const STATUS_NORMAL = 1;
    const STATUS_DELETE = 9;


    public  static function getByObjId($obj_id = '')
    {
        if(!$obj_id) {
            return [];
        }

        return self::select("*", [
            "obj_id" => $obj_id,
            "relate_status" => self::STATUS_NORMAL,
            "ORDER" => [
                "id" => "ASC"
            ]
        ]);
    }

    public  static function getByObjIds($obj_ids = [])
    {
        if(!$obj_ids) {
            return [];
        }
        return self::select("*", [
            "obj_id" => $obj_ids,
            "relate_status" => self::STATUS_NORMAL
        ]);
    }



    public static function insertData($data)
    {

        $ret = self::insert($data);
        if ($ret->errorCode() !== '00000') {
            return false;
        }
        return self::id();
    }

    public static function updateData($data, $obj_id)
    {
        $ret = self::update($data, ["obj_id" => $obj_id]);
        if ($ret->errorCode() !== '00000') {
            return false;
        }
        return true;
    }

}